{template 'web/common/header'}
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <span class="layui-breadcrumb" style="visibility: visible;">
                            <a>商品</a><span lay-separator="">/</span>
                            <a><cite>库存管理</cite></a>
                            <span lay-separator="">/</span>
                            <a><cite>商品调拨</cite></a>
                        </span>
                    </div>
                    <div class="layui-card-body">
                        <table class="layui-hide" id="goods-transfer" lay-filter="goods-transfer"></table>

                        <script type="text/html" id="goods-transfer-toolbar">
                            <div class="layui-btn-container">
                                <button class="layui-btn layui-btn-sm" id="transfer_add">新增调拨</button>
                            </div>
                        </script>

                        <script type="text/html" id="goods-transfer-bar">
                              <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
                              <a class="layui-btn layui-btn-xs" lay-event="detail">入库</a>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="../addons/xn_erp/images/layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../addons/xn_erp/images/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table', 'layer', 'jquery', 'element', 'flow', 'form'], function () {
            var table = layui.table, layer = layui.layer, $ = layui.$, element = layui.element, form = layui.form;
            tables = table.render({
                elem: '#goods-transfer'
                , url: "{$url}&api=list"
                , toolbar: '#goods-transfer-toolbar'
                , title: '商品入存'
                , cols: [[
                    { type: 'checkbox' }
                    , { field: 'record', title: '单号', sort: true, minWidth: 120 }
                    , { field: 'outstorage', title: '调出仓库', sort: true,align: 'center', width: 100 }
                    , { field: 'instorage', title: '调入仓库', sort: true,align: 'center', width: 100 }
                    , { field: 'outdate', title: '调出时间', sort: true,align: 'center', width: 200 }
                    , { field: 'indate', title: '调入时间', sort: true,align: 'center', width: 200 }
                    , { field: 'originator', title: '制单人', sort: true,align: 'center', width: 100 }
                    , { field: 'state', title: '状态', sort: true,align: 'center', width: 100 }
                    , { fixed: 'right', title: '操作', toolbar: '#goods-transfer-bar',  align: 'center',width: 120 }
                ]]
                , page: true
                , limit: 20
            });

            table.on('checkbox(goods-transfer)', function (obj) {
                console.log(obj);
            });

            table.on('tool(goods-transfer)', function (obj) {
                var data = obj.data;
                console.log(obj);
                if (obj.event == 'detail') {
                    
                    layer.open({
                        type: 2,
                        // skin: 'layui-layer-rim', //加上边框
                        title: "调拨明细",
                        area: ['80%', '60%'], //宽高
                        content: 'index.php?c=site&a=entry&do=goods&m=xn_erp&op=transfer_detail&tid=' + data['id']
                    });
                    
                };
            });
            $('#transfer_add').on('click', function () {
                parent.layui.index.openTabsPage('index.php?c=site&a=entry&do=goods&m=xn_erp&op=transfer_add', '新增调拨');
            });
        });
    </script>
</body>
</html>